-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (135 loc) · 4.88 KB
/
CI-CD _worker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: CI-CD_worker
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ tpIntegrador, main ]
paths:
- 'tpIntegrador/example-voting-app-master/worker/**'
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# job to build the microservice
build-microservices:
name: Build worker app
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Install Java JDK with maven
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: maven
# Install java app dependences
- name: Install java app dependences
run: |
cd tpIntegrador/example-voting-app-master/worker/
mvn -B dependency:resolve
# Compile Worker application
- name: Build and test with Maven
run: |
cd tpIntegrador/example-voting-app-master/worker/
mvn -B package --file pom.xml
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: Binary artifact
path: tpIntegrador/example-voting-app-master/worker/target/worker-jar-with-dependencies.jar
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: Test artifact
path: tpIntegrador/example-voting-app-master/worker/target/surefire-reports/*.xml
- name: Report test
uses: dorny/test-reporter@v1
if: always()
with:
name: Test worker service
path: 'tpIntegrador/example-voting-app-master/worker/target/surefire-reports/*.xml'
reporter: java-junit
# job to build and publish docker image
build-and-push-docker-image:
name: Build Docker image and push to repositories
# run only when code is compiling
runs-on: ubuntu-latest
# steps to perform in job
steps:
- name: Checkout code
uses: actions/checkout@v3
# setup Docker build action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build worker image and push to Docker Hub
uses: docker/build-push-action@v2
with:
# relative path to the place where source code with Dockerfile is located
context: ./tpIntegrador/example-voting-app-master/worker/
# Note: tags has to be all lower-case
tags: juandubowez/worker:latest
# build on feature branches, push only on master branch
push: ${{ github.ref == 'refs/heads/tpIntegrador' }}
# job to deploy service to Railway
deploy:
name: Deploy service
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node 16
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Install packages
run: yarn install --frozen-lockfile
- name: Install Railway
run: npm i -g @railway/cli
- name: Deploy worker app
working-directory: ./tpIntegrador/example-voting-app-master/worker/
run: railway up -s worker
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
# job to run integration test service
integration-tests:
name: Integration test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node 16
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Install firefox driver
uses: browser-actions/setup-geckodriver@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}
run: geckodriver --version
- name: Install dependences
run: |
cd tpIntegrador/integration_tests/
npm i --dev
- name: test
working-directory: ./tpIntegrador/integration_tests/
run: |
npm test
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Integration tests Results # Name of the check run which will be created
path: 'tpIntegrador/integration_tests/test-results.xml' # Path to test results
reporter: jest-junit